package com.md01.service;

import com.md01.entity.Book;
import com.md01.mapper.BookMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class BookServiceImpl implements BookService {
    //1、先写注解
    //2、再写自动装配
    //3、把BookService代码复制，并删除注解
    //3、继承，实现方法
    @Autowired
    private BookMapper bookMapper;


    @Override
    public List<Book> selectAllBooks() {
        return bookMapper.selectAllBooks();
    }

    @Override
    public Book selectBookById(int id) {
        return bookMapper.selectBookById(id);
    }

    @Override
    public int deleteBookById(int id) {
        return bookMapper.deleteBookById(id);
    }

    @Override
    public int insertBook(Book book) {
        return bookMapper.insertBook(book);
    }

    @Override
    public int updateBook(Book book) {
        return bookMapper.updateBook(book);
    }

    @Override
    public List<Book> selectBookByBookName(String bookName) {
        return bookMapper.selectBookByBookName(bookName);
    }
}
